Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol Fee Table #964

Merged
merged 18 commits into from
Dec 5, 2024
Merged

Protocol Fee Table #964

merged 18 commits into from
Dec 5, 2024

Conversation

0xlucian
Copy link
Contributor

@0xlucian 0xlucian commented Oct 1, 2024

Fix #956

@0xlucian 0xlucian changed the title Fee Table Implementation Protocol Fee Table Oct 1, 2024
@coveralls
Copy link

coveralls commented Oct 1, 2024

Coverage Status

coverage: 98.938% (-0.01%) from 98.948%
when pulling 1f8f486 on 212-protocol-fee-table
into 6353182 on main.

Copy link
Member

@zajck zajck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I just added some suggestions for improvements.

contracts/interfaces/events/IBosonConfigEvents.sol Outdated Show resolved Hide resolved
contracts/protocol/bases/ProtocolBase.sol Outdated Show resolved Hide resolved
contracts/protocol/bases/ProtocolBase.sol Outdated Show resolved Hide resolved
contracts/protocol/bases/ProtocolBase.sol Outdated Show resolved Hide resolved
contracts/protocol/bases/ProtocolBase.sol Outdated Show resolved Hide resolved
contracts/protocol/facets/ConfigHandlerFacet.sol Outdated Show resolved Hide resolved
contracts/protocol/facets/ConfigHandlerFacet.sol Outdated Show resolved Hide resolved
contracts/protocol/facets/ConfigHandlerFacet.sol Outdated Show resolved Hide resolved
contracts/protocol/facets/ConfigHandlerFacet.sol Outdated Show resolved Hide resolved
test/protocol/ConfigHandlerTest.js Outdated Show resolved Hide resolved
@0xlucian 0xlucian requested a review from zajck October 2, 2024 11:07
Copy link
Member

@zajck zajck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small natspec change.

contracts/protocol/facets/ConfigHandlerFacet.sol Outdated Show resolved Hide resolved
@0xlucian 0xlucian requested a review from zajck October 2, 2024 12:11
zajck
zajck previously approved these changes Oct 2, 2024
Copy link
Member

@zajck zajck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// If the token has a custom fee table, find the appropriate percentage
uint256 priceRangesLength = priceRanges.length;
if (priceRangesLength > 0) {
for (uint256 i; i < priceRangesLength; ++i) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (uint256 i; i < priceRangesLength; ++i) {
for (uint256 i; i < priceRangesLength - 1; ++i) {

I guess it should give the same result saving a few instruction/gas (at least 1 if() assessment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Good catch.

*/
function setTokenPriceRanges(address _tokenAddress, uint256[] calldata _priceRanges) internal {
for (uint256 i = 1; i < _priceRanges.length; ++i) {
if (_priceRanges[i] < _priceRanges[i - 1]) revert NonAscendingOrder();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (_priceRanges[i] < _priceRanges[i - 1]) revert NonAscendingOrder();
if (_priceRanges[i] <= _priceRanges[i - 1]) revert NonAscendingOrder();

I don't think it makes sense to accept 2 successive ranges with the same value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Fixed.

test/protocol/ConfigHandlerTest.js Show resolved Hide resolved
test/protocol/ConfigHandlerTest.js Show resolved Hide resolved
@0xlucian 0xlucian requested a review from zajck December 4, 2024 06:36
Copy link
Member

@zajck zajck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@levalleux-ludo levalleux-ludo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@0xlucian 0xlucian merged commit 7818ce6 into main Dec 5, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Protocol fee table
4 participants